Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use nyc instead of config.nyc in package.json #132

Conversation

jamestalmage
Copy link
Member

Fixes #131

This also uses pkg-up to locate the nearest package.json from cwd, and will move cwd to there. This allows you to invoke nyc from a subdirectory of your project and still have it behave as expected. This is something our caching mechanism already does. If it can't find a package.json, it just uses the original cwd option.

@novemberborn
Copy link
Contributor

LGTM

var config = require(path.resolve(this.cwd, './package.json')).config || {}
config = config.nyc || {}
var config
if (pkgPath) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the constructor is getting pretty verbose at this point, mind moving the config logic into a private method, e.g., _loadConfig.

@bcoe
Copy link
Member

bcoe commented Jan 4, 2016

@jamestalmage looks good, just a couple comments.

Fixes istanbuljs#131

This also uses `pkg-up` to locate the nearest `package.json` from `cwd`, and will move `cwd` to there. This allows you to invoke `nyc` from a subdirectory of your project and still have it behave as expected.  This is something our caching mechanism already does. If it can't find a `package.json`, it just uses the original `cwd` option.
@jamestalmage jamestalmage force-pushed the use-top-level-nyc-config-in-pkg-json branch from 9a1bded to 434dd99 Compare January 4, 2016 23:24
jamestalmage added a commit that referenced this pull request Jan 5, 2016
…-pkg-json

Use `nyc` instead of `config.nyc` in package.json
@jamestalmage jamestalmage merged commit 1c5d25f into istanbuljs:master Jan 5, 2016
@jamestalmage jamestalmage deleted the use-top-level-nyc-config-in-pkg-json branch January 5, 2016 02:51
@@ -59,6 +60,24 @@ function NYC (opts) {
this.loadedMaps = null
}

NYC.prototype._loadConfig = function (opts) {
var cwd = opts.cwd || process.env.NYC_CWD || process.cwd()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rock on \o/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants